//
//  LBHPerson.m
//  iOSDemo
//
//  Created by Steve on 2021/3/8.
//

#import "LBHPerson.h"

@implementation AddCalculator

- (AddCalculator * (^)(NSInteger sumresult))add
{
    return^(NSInteger sumresult){
        self->_sumresult  += sumresult;
        return self;
    };
}
@end


@implementation LBHPerson

- (void)personInstanceMethod
{
    NSLog(@"1");
}

- (LBHPerson *(^)(NSString *food))eat
{
    NSLog(@"%s", __FUNCTION__);
    
    return ^(NSString *food){
        NSLog(@"吃：%@ ",food);

        return self;
    };
}

- (LBHPerson *(^)(NSString *where))sleep
{
    NSLog(@"%s", __FUNCTION__);
    return ^(NSString *where){
        NSLog(@"睡在：%@上",where);
        return self;
    };
}


- (LBHPerson *)calculator:(NSInteger(^)(NSInteger result))block
{
    _result = block(_result);
    return self;
}

- (LBHPerson *)makecalculator:(void (^)(AddCalculator *addcalculator))block
{
    
    AddCalculator *add = [[AddCalculator alloc]  init];
    if (block) {
        block(add);
    }
    self.result = add.sumresult;
    return self;
}
@end
